package com.baizhi.method;

/**
 *  获取线程信息的相关方法
 */
public class ThreadInfoDemo {
    public static void main(String[] args) {



        //获取主线程
        Thread main = Thread.currentThread();
        System.out.println(main);

        //获取主线程的名字
        String name = main.getName();
        System.out.println(name);

        //获取主线程的id
        long id = main.getId();
        System.out.println(id);

        //获取主线承担额优先级 ：优先级对应整数 1-10  默认是5
        int priority = main.getPriority();
        System.out.println("主线程的优先级是："+priority);

        //判断线程是否活着
        boolean alive = main.isAlive();
        System.out.println("线程还活着："+alive);

        //是否是守护线程
        boolean daemon = main.isDaemon();
        System.out.println("main线程是否是守护线程："+daemon);

        //线程是否中断
        boolean interrupted = main.isInterrupted();
        System.out.println("线程是否中断："+interrupted);
    }
}
